#{extends 'main.html' /}

<h1>Add a new offer</h1>
<br>
<div id="styledForm">
#{form @Offers.save(), enctype:'multipart/form-data'}
    <fieldset>              
        <legend>Offer information</legend>  

        <div class="field">
            <label for="startDateString">From</label>                  
            <input id="startDateString" type="date" name="startDateString" size="30" value="${flash.startDateString}" class="#{errorClass 'startDateString' /}" /> 
            <span class="error">#{error 'startDateString' /}</span>
        </div>
        
        <div class="field">
            <label for="endDateString">To</label>                  
            <input id="endDateString" type="date" name="endDateString" size="30" value="${flash.endDateString}" class="#{errorClass 'endDateString' /}" /> 
            <span class="error">#{error 'endDateString' /}</span>
        </div>
        
        <div class="field">
            <label for="street">street</label>                  
            <input id="street" type="text" name="street" size="30" value="${flash.street}" class="#{errorClass 'street' /}" /> 
            <span class="error">#{error 'street' /}</span>
        </div>     
        
        <div class="field">
            <label for="streetNumber">street number</label>                  
            <input id="streetNumber" type="text" name="streetNumber" size="30" value="${flash.streetNumber}" class="#{errorClass 'streetNumber' /}" /> 
            <span class="error">#{error 'streetNumber' /}</span>
        </div>
        
        <div class="field">
            <label for="city">City</label>                  
            <input id="city" type="text" name="city" size="30" value="${flash.city}" class="#{errorClass 'city' /}" /> 
            <span class="error">#{error 'city' /}</span>
        </div> 
        
        <div class="field">
            <label for="zipcode">Zip Code</label>                  
            <input id="zipcode" type="text" name="zipcode" size="10" value="${flash.zipcode}" class="#{errorClass 'zipcode' /}" /> 
            <span class="error">#{error 'zipcode' /}</span>
        </div>   
        
        <div class="field">
            <label for="size">Room size</label>                  
            <input id="size" type="text" name="size" size="5" value="${flash.size}" class="#{errorClass 'size' /}" />  Square meters
            <span class="error">#{error 'size' /}</span>
        </div>
        
        <div class="field">
            <label for="price">Room price</label>                  
            <input id="price" type="text" name="price" price="5" value="${flash.price}" class="#{errorClass 'price' /}" /> Euro
            <span class="error">#{error 'price' /}</span>
        </div>                  
        
        <div class = "field"> 
			<label for = "event">Event</label>
			#{select id:'eventId', name:'eventId', value:flash.eventId}
				#{list items:events, as:'event'}
					#{if event.endDate == event.startDate}
						#{option value=event.id}${event.name}, on ${event.startDate.format('dd.MM.yyyy')}, ${event.city}#{/option}
					#{/if}#{else}
						#{option value=event.id}${event.name}, from ${event.startDate.format('dd.MM.yyyy')} to ${event.endDate.format('dd.MM.yyyy')}, ${event.city}#{/option}
					#{/else}
				#{/list}
			#{/select}
        </div>
        
        <div class="field">     
            <label for="description">Description</label>                    
            <textarea id="description" type="text" name="description" rows = "5" cols = "50" class="#{errorClass 'description' /}">${flash.description}</textarea>
            <span class="error">#{error 'description' /}</span>
       	</div>
       	
        <div class="field">
         <label for="picture">Image</label>
         <input type="file" name="picture" value = "${flash.picture}" class="#{errorClass 'picture' /}" />
         <span class="error">#{error 'picture' /}</span>
        </div>  
        
       	<div class="field">
 			<label for="premium">Premium Offer?</label>
			<input type="checkbox" name="premium" value="true" ${flash.premium ? 'checked="true"' : ''}>
		</div>
        
          
        
    </fieldset>
    <span class="error">${flash.existentError}</span><br>          
                    
    <input type="submit" class="submit" value="create offer" />
    
#{/form}
</div>
